package com.ecoolex.discount.sales.ws;

import java.time.Instant;
import java.util.Date;

import com.ecoolex.discount.sales.entity.DiscountBrandWithBLOBs;
import com.ecoolex.discount.sales.pojo.QueryCouponBatchDTO;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.discount.sales.core.service.UplanCouponBatchService;
import com.ecoolex.discount.sales.entity.UPlanCouponBatch;
import com.ecoolex.discount.sales.pojo.AddCouponBatchDTO;

@Service
public class CouponBatchServiceImpl implements CouponBatchService {
	@Autowired
	UplanCouponBatchService uplanCouponBatchService;

	@Override
	public UPlanCouponBatch addBatch(AddCouponBatchDTO dto, String batchNo, String user) {
		UPlanCouponBatch batch = new UPlanCouponBatch();
		batch.setBatchCode(batchNo);
		batch.setBatchName(dto.getBatchName());
		batch.setPromotionCode(dto.getPromotionCode());
		batch.setNotes(dto.getNotes());
		batch.setStatus(1L);
		Date now = Date.from(Instant.now());
		batch.setCreateTime(now);
		batch.setCreateUser(user);
		batch.setUpdateTime(now);
		batch.setUpdateUser(user);
		return uplanCouponBatchService.addBatch(batch);
	}

	@Override
	public Pagination<DiscountBrandWithBLOBs> couponBatchList(QueryCouponBatchDTO query, Sorting[] sorts, Page page) {
		return null;
	}
}
